var dom = document.getElementById("container");
var myChart = echarts.init(dom);
var app = {};

var option;



option = {
  // 全局调色盘。
  color: [
    '#36d36d',
    // '#2f4554',
    // '#61a0a8',
    // '#d48265',
    // '#91c7ae',
    // '#749f83',
    // '#ca8622',
    // '#bda29a',
    // '#6e7074',
    // '#546570',
    // '#c4ccd3'
  ],
  title: {
    text: '二叉树'
  },
  tooltip: {},
  animationDurationUpdate: 100,
  animationEasingUpdate: 'quinticInOut',
  series: [{
    type: 'graph',
    layout: 'none',
    symbolSize: 50,
    roam: true,
    label: {
      show: true
    },
    edgeSymbol: ['circle', 'none'],
    edgeSymbolSize: [4, 10],
    edgeLabel: {
      fontSize: 20
    },
    data: [{
      name: '节点1',
      x: 300,
      y: 300
    }, {
      name: '节点2',
      x: 800,
      y: 300
    }, {
      name: '节点3',
      x: 550,
      y: 100
    }, {
      name: '节点4',
      x: 200,
      y: 500
    }, {
      name: '节点5',
      x: 400,
      y: 500
    }, {
      name: '节点6',
      x: 700,
      y: 500
    }, {
      name: '节点7',
      x: 900,
      y: 500
    }, {
      name: '第0层',
      x: 0,
      y: 100
    }, {
      name: '第1层',
      x: 0,
      y: 300
    }, {
      name: '第2层',
      x: 0,
      y: 500
    }],
    // links: [],
    links: [
      //     {
      //     source: 0,
      //     target: 1,
      //     symbolSize: [5, 20],
      //     label: {
      //         show: true
      //     },
      //     lineStyle: {
      //         width: 5,
      //         curveness: 0.2
      //     }
      // }, 
      {
        source: '300',
        target: '100',
        label: {
          show: true
        },
        lineStyle: {
          curveness: 0.2
        }
      }, {
        source: '节点3',
        target: '节点1'
      }, {
        source: '节点1',
        target: '节点4'
      }, {
        source: '节点1',
        target: '节点5'
      }, {
        source: '节点3',
        target: '节点2'
      }, {
        source: '节点2',
        target: '节点6'
      }, {
        source: '节点2',
        target: '节点7'
      }, {
        source: '第0层',
        target: '节点3'
      }, {
        source: '第1层',
        target: '节点1'
      }, {
        source: '第2层',
        target: '节点4'
      }
    ],
    lineStyle: {
      opacity: 0.9,
      width: 2,
      curveness: 0
    }
  }]
};

if (option && typeof option === 'object') {
  myChart.setOption(option);
}